<template>
  <div class="ehb all">
    <ehb-header :service-name="title"></ehb-header>
    <ehb-content-row2 v-bind:row-data-list="items"></ehb-content-row2>
    <ehb-footer></ehb-footer>
  </div>
</template>

<script>
import { getMenu } from "../../api/zwfw-service";

export default {
  name: "index",
  data() {
    let serviceArea = this.$globalEnv.serviceArea
    return {
      title: `${serviceArea}不动产网上办事大厅`,
      icons: {
        'icon-wyb': require('../../assets/img/icon-wyb.png'),
        'icon-wyc': require('../../assets/img/icon-wyc.png'),
        'icon-wyk': require('../../assets/img/icon-wyk.png'),
        'icon-wyw': require('../../assets/img/icon-wyw.png')
      },
      items: [],
      arrData: []
    }
  },
  mounted() {
    let that = this;
    if (["hsRegister", "snjRegister", "jzRegister", "ezRegister"].includes(that.GLOBAL.urlType)) {
      that.getMenuList();
    } else {
      let resJsonInfo = this.GLOBAL.jdInfo[this.GLOBAL.urlType];
      this.jdmc = resJsonInfo.jdmc;
      this.provider = resJsonInfo.provider;
      ehbAppJssdk.network.request({
        url: that.GLOBAL.urlConfig.getJdYwlx[that.GLOBAL.urlType],
        method: 'post',
        data: {
          "jdid": resJsonInfo.id,
          "sfsx": '0'
        },
        headers: { 'contentType': 'application/x-www-form-urlencoded' },
        success: function (data) {
          if (data.status == 0) {
            let result = data.result;
            for (let i in result) {
              let res = result[i];
              let url = "";
              resJsonInfo = { ...resJsonInfo, ...res };
              if (res.ywlxbm == "005") {
                resJsonInfo.ywlxbm = "005";
                url = "/onlineProcessing/Qkysfzydj";
              }
              if (res.ywlxbm == "006") {
                resJsonInfo.ywlxbm = "006";
                url = "/onlineProcessing/Ybdydj";
              }
              if (res.ywlxbm == "0061") {
                resJsonInfo.ywlxbm = "0061";
                url = "/onlineProcessing/FdZgedydj";
              }
              if (res.ywlxbm == "007") {
                resJsonInfo.ywlxbm = "007";
                url = "/onlineProcessing/Dyzxdj";
              }
              if (res.ywlxbm == "010") {
                resJsonInfo.ywlxbm = "010";
                url = "/onlineProcessing/Esfzydj";
              }
              if (res.ywlxbm == "011") {
                resJsonInfo.ywlxbm = "011";
                url = "/onlineProcessing/Bgdj";
              }
              if (res.ywlxbm == "012") {
                resJsonInfo.ywlxbm = "012";
                url = "/onlineProcessing/Ygdj";
              }
              if (res.ywlxbm == "008") {
                resJsonInfo.ywlxbm = "008";
                url = "/onlineProcessing/Gyjsydsyqjfwsyqzxdj";
              }
              if (res.ywlxbm == "002") {
                resJsonInfo.ywlxbm = "002";
                url = "/onlineProcessing/Ygspfdyygdj";
              }
              if (res.ywlxbm == "004") {
                resJsonInfo.ywlxbm = "004";
                url = "/onlineProcessing/Ygspfdyygzxdj";
              }
              if (res.ywlxbm !== "010") {
                that.arrData.push({ "name": res.ywlxmc, "url": url, ...resJsonInfo });
              }
            }
            that.getMenuList();
          } else {
            that.toNOData("没有查询到该节点的业务信息");
          }
        },
        fail: function (res) {
          that.getMenuList();
        }
      });
    }

  },
  methods: {
    getMenuList() {
      getMenu().then(res => {
        if (res.status == 0 && res.result && res.result.length > 0) {
          this.items = [...res.result];
          for (let i in this.items) {
            this.items[i].url = '/menu'
            this.items[i].icon = this.icons[this.items[i].icon]
            this.items[i].params = { ...res.result[i] };
            if (["hsRegister", "snjRegister", "jzRegister", "ezRegister", "tmRegister"].includes(this.GLOBAL.urlType)) {
              this.items[i].params.children = this.getNewChildren(this.items[i].name, this.items[i].params.children);
            }
          }
        } else {
          ehbAppJssdk.notice.alert({
            title: '提示',
            message: '未查询到菜单!',
            buttonName: '收到',
          });
        }
      })
    },
    getNewChildren(name, children) {
      let jdxx = this.GLOBAL.jdInfo[this.GLOBAL.urlType];
      if (name === "我要查") {
        let ezItems = [];
        if (this.GLOBAL.urlType === "tmRegister") {
          ezItems = [
            { "name": "不动产权属信息查询", "url": "/estateInfo", "icon": require('../../assets/img/ico-1bdccx.png'), ...jdxx },
            //{"name":"我的申请","url":"/onlineProcessing/MyApplication","icon":require('../../assets/img/ico-7wdsq.png'),...jdxx},
          ];
        } else {
          ezItems = [
            //{"name": "我的申请", "url": "/onlineProcessing/MyApplication", "icon": require('../../assets/img/ico-7wdsq.png'), ...jdxx}
          ];
        }
        return children.concat(ezItems);
      }
      if (name === "我要看") {
        let ezItems = [];
        if (this.GLOBAL.urlType === "tmRegister") {
          ezItems = [
            { "name": "法律法规", "url": "/law", "icon": require("../../assets/img/ico-4flfg.png"), ...jdxx },
            { "name": "办事指南", "url": "/workGuide", "icon": require("../../assets/img/ico-5bszn.png"), ...jdxx },
            { "name": "办理网点", "url": "/network/network", "icon": require('../../assets/img/ico-8blwd.png'), ...jdxx },
          ];
        }
        let wyk = [];
        if (children && children.length >= 0) {
          wyk = children.concat(ezItems)
        } else {
          wyk = ezItems;
        }

        return wyk;
      }
      if (name === "我要办") {
        let ezItems = [];
        if (this.GLOBAL.urlType !== "tmRegister") {
          ezItems = [
            // {"name": "待缴税", "url": "/tax/djsList", "icon": require('../../assets/img/ico-11fjd.png'), ...jdxx},
            // {"name": "确认", "url": "/qr", "icon": require('../../assets/img/ico-11fjd.png'), ...jdxx},
            { "name": "待缴税", "url": "/tax/djsList", "icon": require('../../assets/img/ico-11fjd.png'), ...jdxx },
            // {"name": "待缴费", "url": "/pay/payList", "icon": require('../../assets/img/ico-11fjd.png'), ...jdxx}
          ];
        }
        let arr = this.arrData.concat(children);
        return arr.concat(ezItems);
      }
      if (name === "我要问") {
        let ezItems = [];
        let arr = this.arrData.concat(children);
        return arr;
      }
    }
  }
}
</script>

<style scoped>
</style>
